<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>抵押信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
 <div class="Wrapper">
           <div id="pageInTab" class="pageInTab">
            <!--   <div tabid="tabA" title="基本信息" lselected="true"> -->
                    <form id="prj_prd_mtg_info_form">
                        <div class="fieldset1 tabel_col clearFix">
                         <div class="fieldBox col_50">
				                    <div class="label">登记编号</div>
				                    <div class="field">
				                        <input name="recNo"  id="recNo" type="text" class="ui-textbox" value="${mtg.recNo }" validate="{required:true}" >
				                     <span class="requiredSymbol">*</span>
				                    </div>
		               		 </div>
		               		 
		               		  <div class="fieldBox col_50">
				                    <div class="label">抵押期限</div>
				                    <div class="field">
				                     <c:if test="${detailFlag==true }">
				                   		  <span   id="mtgDeadlineTxt" >${mtg.mtgDeadline}</span>
				                        </c:if>
				                        <c:if test="${detailFlag!=true }">
				                        <input name="mtgDeadline"  id="mtgDeadline" type="text" class="ui-datepicker"  onblur="setIsWithoutDayValue();" value="${mtg.mtgDeadline}" >
				                        </c:if>
				                          <input type="checkbox" id="isWithoutDay" name="isWithoutDay"   onchange="setMtgDeadlineValue();"
				                          <c:if test="${mtg.isWithoutDay==1 }">
				                          checked="checked"
				                          </c:if>
				                          />无限期
				                    </div>
		               		 </div>
							<div class="fieldBox col_50">
								<div class="label">抵押方式</div>
								<div class="field">
									<select name="mtgWayCd"  id="mtgWayCd" onchange='changePledgeeAuthNm(this);'>
										<c:set var="insflag" value="1" />
										<c:if test="${insflag==1}">
											<c:forEach items="${mtgInsList}" var="insObj">
												<c:if test="${insObj.key==insCode }">
													<option value="4">资方机构</option>
													<c:set var="insflag" value="2" />
												</c:if>
											</c:forEach>
										</c:if>
										<c:if test="${insflag==1}">
											<c:forEach items="${mtgWayList}" var="wayObj" >
												<c:if test="${wayObj.key!='4'}"><!--当第三方机构不为微众/三井时 去掉资方机构抵押方式  -->
													<option  value="${wayObj.key}" <c:if test="${mtg.mtgWayCd==wayObj.key }">
														selected='selected'</c:if>
													>${wayObj.value}</option>
												</c:if>
											</c:forEach>
										</c:if>
									</select><span class="requiredSymbol">*</span>
								</div>
							</div>
		               		        <div class="fieldBox col_50" >
					              <div class="label">抵押人</div>
					                <div class="field">
					                <select name="mtgPsnTypCd"  id="mtgPsnTypCd" >
					                 <option value="" selected="selected">--请选择--</option>
					                 <c:forEach items="${mtgPsnTypCdList}" var="opt">
					                  <option value="${opt.key}"
					                  <c:if test="${mtg.mtgPsnTypCd==opt.key }">selected='selected'</c:if>
					                  >${opt.value}</option>
					                 </c:forEach>
					                </select>
					                  <span class="requiredSymbol">*</span>
					                </div>
					            </div>
					            
					            <div class="fieldBox col_50">
				                    <div class="label">抵押序号</div>
				                    <div class="field">
				                        <input name="sortNo"  id="sortNo" type="text" class="ui-textbox" value="${mtg.sortNo }" >
				                    </div>
		               		 </div>
		               		 
		               		   <div class="fieldBox col_50" >
					              <div class="label">抵押物种类</div>
					                <div class="field">
					                <select name="guarTypCd"  id="guarTypCd" >
					                 <option value="" selected="selected">--请选择--</option>
					                 <c:forEach items="${guarTypCdList}" var="opt">
					                  <option value="${opt.key}"
					                  	 <c:if test="${mtg.guarTypCd==opt.key }">selected='selected'</c:if>
					                  >${opt.value}</option>
					                 </c:forEach>
					                </select>
					                  <span class="requiredSymbol">*</span>
					                </div>
					            </div>
		                      <div class="fieldBox col_50">
				                    <div class="label">客户名称</div>
				                    <div class="field">
				                 		  <span>${cst.cstNm}</span>
				                    </div>
		               		 </div>
		               		  <div class="fieldBox col_100">
				                    <div class="label">所住地</div>
				                    <div class="field">
					                    <c:if test="${cst.cstTypCd==CustomerConstant.CST_TYPE_NP_CD }">
					                    <span>${cst.cstNpBscInfoVO.homeAddr}</span>
					                    </c:if>
					                      <c:if test="${cst.cstTypCd==CustomerConstant.CST_TYPE_CORP_CD }">
					                    <span>${cst.cstCorpBscInfoVO.postAddr}</span>
					                    </c:if>
				                    </div>
		               		 </div>
		               		   <div class="fieldBox col_50">
				                    <div class="label">证件类型</div>
				                    <div class="field">
				                      <span>${cst.certTypCdNm}</span>
				                    </div>
		               		 </div>
		               		  <div class="fieldBox col_50">
				                    <div class="label">证件号码</div>
				                    <div class="field">
				                    <span>${cst.certNo}</span>
				                    </div>
		               		 </div>
		               		  
		               		   <div class="fieldBox col_100">
				                    <div class="label">抵押物说明</div>
				                    <div class="field">
				                   <textarea name="guarDesc" id="guarDesc"    rows="4"  class="ui-textarea l-textarea" style="width:80%"  value=""  >${mtg.guarDesc}</textarea>
				                    </div>
		               		 </div>
							<c:if test="${mtg.pledgeeAuthNm ==null || mtg.pledgeeAuthNm =='' }">
								<div class="fieldBox col_50">
									<div class="label">抵押权人名称（姓名）</div>
									<div class="field">
										<!--modify 项目资方，仅支持微众、三井 ,显示资方名称，其他显示狮桥   -->
										<span id="pledgeeAuthNmDiv1">
					                       <c:set var="insflag" value="1" />
		                  			 		<c:if test="${insflag==1}">
												<c:forEach items="${mtgInsList}" var="insObj">
													<c:if test="${insObj.key==insCode }">
														${insObj.value }
														<c:set var="insflag" value="2" />
													</c:if>
												</c:forEach>
											</c:if>
				                  			<c:if test="${insflag==1}">
												<c:if test="${mtg.mtgWayCd==null || mtg.mtgWayCd=='' || mtg.mtgWayCd=='1' }"><!-- 抵押方式为无法抵押、上户自有公司：抵押权人姓名为空  -->
													<span id="pledgeeAuthNmDiv">狮桥融资租赁中国有限公司</span>
												</c:if>
											</c:if>
										</span>
									</div>
								</div>
							</c:if>
							<%--<c:if test="${mtg.pledgeeAuthNm !=null}">
			          		  <div class="fieldBox col_50">
					                    <div class="label">抵押权人名称（姓名）</div>
					                    <div class="field">
											<select name="pledgeeAuthNm" id="pledgeeAuthNm" data-value="${pledgeeAuthNm }" >
												<c:forEach items="${pledgeeNmList }" var="kv">
													<c:if test="${mtg.pledgeeAuthNm == kv.key }">
														<option value="${kv.key }" selected>${kv.value }</option>
													</c:if>
													<c:if test="${mtg.pledgeeAuthNm != kv.key }">
														<option value="${kv.key }">${kv.value }</option>
													</c:if>
												</c:forEach>
											</select>
					                    </div>
			               	  </div>
		               		</c:if>--%>
							<c:if test="${mtg.pledgeeAuthNm !=null}">
								<div class="fieldBox col_50">
									<div class="label">抵押权人名称（姓名）</div>
									<div class="field">
					                     <span id="pledgeeAuthNmDiv2">
						                     <c:if test="${mtg.mtgWayCd==null || mtg.mtgWayCd=='' || mtg.mtgWayCd=='1' || mtg.mtgWayCd=='4'}"><!-- 抵押方式为无法抵押、上户自有公司：抵押权人姓名为空  -->
						                    	<c:forEach items="${pledgeeNmList }" var="kv">
													<c:if test="${mtg.pledgeeAuthNm == kv.key }">
														<span>${kv.value}</span>
													</c:if>
												</c:forEach>
						                      </c:if>
					                     </span>
									</div>
								</div>
							</c:if>
							<div class="fieldBox col_50">
				                    <div class="label">证件类型</div>
				                    <div class="field">
				                      <span>${certType}</span>
				                    </div>
		               		 </div>
		               		 
		               		   <div class="fieldBox col_50">
				                    <div class="label">证件号码</div>
				                    <div class="field">
				                      <span>${certNo}</span>
				                    </div>
		               		 </div>     		 
		                <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div id="feePayGrid">
				                    	 <div id="prdGrid" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
		               		   <div class="fieldBox col_100">
				                    <div class="label">债权人声明：</div>
				                    <div class="field">
				                    <span>
				                    本登记书所填写内容完全符合《物权法》有关规定，我方为登记书所填的内容真实性、合法性承担全部责任。
				                    </span>
				                    </div>
		               		 </div>
		               		  <div class="fieldBox col_50">
				                    <div class="label">签字:</div>
				                    <div class="field">
				                        <input name="pledgorNm"  id="pledgorNm" type="text" class="ui-textbox" value="${mtg.pledgorNm }" validate="{required:true}">
				                        <input type="checkbox" id="isLnkCompNm" name="isLnkCompNm"   onchange="setPledgorNm();"
				                          <c:if test="${mtg.pledgorNm==lnkCompNm}">
				                          checked="checked"
				                          </c:if>
				                          />挂靠公司
				                     <span class="requiredSymbol">*</span>
				                    </div>
		               		 </div>
		               		   <div class="fieldBox col_50">
				                    <div class="label">日期:</div>
				                    <div class="field">
				                   		 <c:if test="${detailFlag==true }">
				                   		  <span   id="pledgorSignDtTxt" >${mtg.pledgorSignDt}</span>
				                        </c:if>
				                        <c:if test="${detailFlag!=true }">
				                        <input name="pledgorSignDt"  id="pledgorSignDt"  type="text"  class="ui-datepicker"  onblur="setMtgDate();" value="${mtg.pledgorSignDt}" validate="{required:true}" >
				                       <span class="requiredSymbol">*</span>
				                        </c:if>
				                    </div>
		               		 </div>
		               		    <div class="fieldBox col_100">
				                    <div class="label"> 抵押权人声明：</div>
				                    <div class="field">
				                      <span>
				                      		   本登记书所填写内容完全符合《物权法》有关规定，我方为登记书所填事项的真实性、合法性承担全部责任。
				                      </span>
				                    </div>
		               		 </div>
		               		    <div class="fieldBox col_50">
				                    <div class="label"> 签字</div>
				                    <div class="field">
				                        <input name="pledgeeNm"  id="pledgeeNm" type="text" class="ui-textbox" value="${mtg.pledgeeNm }" validate="{required:true}" readonly="readonly">
				                      <span class="requiredSymbol">*</span>
				                    </div>
		               		 </div>
		               		   <div class="fieldBox col_50">
				                    <div class="label"> 日期</div>
				                    <div class="field">
				                    <c:if test="${detailFlag==true }">
				                   		  <span   id="pledgeeSignDtTxt" >${mtg.pledgeeSignDt}</span>
				                        </c:if>
				                        <c:if test="${detailFlag!=true }">
				                        <input name="pledgeeSignDt"  id="pledgeeSignDt" type="text"  class="ui-datepicker"  value="${mtg.pledgeeSignDt}"  validate="{required:true}" >
				                          <span class="requiredSymbol">*</span>
				                        </c:if>
				                    </div>
		               		 </div>
		               		   		    <div class="fieldBox col_50">
				                    <div class="label"> 登记机关</div>
				                    <div class="field">
				                      <input name="licOrgNm"  id="licOrgNm" type="text" class="ui-textbox" value="${mtg.licOrg.licOrgNm }"  onFocus="selectLicOrg();" validate="{required:true}" >
				                       <input name="orgId"  id="orgId" type="hidden" class="ui-textbox" value="${mtg.licOrg.id }" >
				                              <span class="requiredSymbol">*</span>
				                    </div>
		               		 </div>
		               		   <div class="fieldBox col_50">
				                    <div class="label"> 日期</div>
				                    <div class="field">
				                        <c:if test="${detailFlag==true }">
				                   		  <span   id="regAuthSignDtTxt" >${mtg.regAuthSignDt}</span>
				                        </c:if>
				                        <c:if test="${detailFlag!=true }">
				                        <input name="regAuthSignDt"  id="regAuthSignDt" type="text"  class="ui-datepicker"  value="${mtg.regAuthSignDt}" validate="{required:true}" >
				                          <span class="requiredSymbol">*</span>
				                        </c:if>
				                    </div>
		               		 </div>
		       <div class="fieldset1 tabel_col tabel_col_s clearFix">
	                            <div class="caption">
	                                <span class="title">上传附件信息 </span>
	                            </div>
	                      <c:if test="${detailFlag!=true }">
			           	 <div class="fieldBox col_100" id="fileDetail">
			                    <div class="label">资料上传</div>
			                    <div class="field">
			                    	<jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
			                    		<jsp:param name="filePath" value="prjprdmtginfo"/>
			                    	</jsp:include>
			                    	<input name="mtgId" id="mtgId" type="hidden" value="${mtg.id }">
			                    </div>
			               </div>
			              </c:if>
			           <c:if test="${detailFlag==true }">
			             <div class="fieldBox col_100" id="fileModify">
		                    <div class="label">资料</div>
		                    <div class="field">
		                    	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
		                    		<jsp:param name="pkId" value="${mtg.id }"/>
		                    		<jsp:param name="tabNm" value="PRJ_PRD_MTG_INFO"/>
		                    	</jsp:include>
		                    </div>
		               	 </div>  
			           </c:if>
			               
			            <c:if test="${detailFlag!=true }">
			                   <div class="fieldBox col_100" id="fileModify">
			                    <div class="label">资料</div>
			                    <div class="field">
			                    	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" >
			                    		<jsp:param name="pkId" value="${mtg.id }"/>
			                    		<jsp:param name="tabNm" value="PRJ_PRD_MTG_INFO"/>
			                    	</jsp:include>
			                    </div>
			               	 </div>  
		               	 </c:if>
		               	 
	               </div>
                              <div class="fieldBox col_50"  style="display: none">
                                <div class="field"> 
                              		<input name="mtgId" id="mtgId" type="text"  value="${mtg.id }" >
                              		<input name="dtlId" id="dtlId" type="text"  value="${mtg.dtlId }" >
                                </div>
                            </div>
                            </div>
                 <!--    </div> -->
                    <!--  <div tabid="tabB" title="抵押资料" id="tabBId" style="display: none;">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
          			 </div>  -->
                     <div class="btnsBox">
		                <span id="prj_prd_mtg_info_add_btn_id" class="sq-button sq-button-round" onclick="savePrjPrdMtg();"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
		                <c:if test="${checkDy==1 }">
			                <span id="passDyId" class="sq-button sq-button-round" onclick="passDy(${id},${mtg.mtgWayCd});">验证通过</span>
		                </c:if>
         			</div>
         			  <c:if test="${checkDy == 0 }">
                   <div>
                    	 <span id="YD"  onClick=" YanZ();" class="sq-button sq-button-round"  value= "2" >验证通过</span>
                    	 <span id="YD1"  onClick=" NotYanZ();" class="sq-button sq-button-round" value= "1"  >验证不通过</span>
                   </div>
                   </c:if>
                    </form>
                   
                    </div>
	</div>

<script type="text/javascript">
var pageInApp={
		flag:true
};
var detailFlag = '${detailFlag}'; 
var id = '${id}';
var dtlId = '${dtlId}';
var cstNm = '${cst.cstNm}';
var buOrgCd = '${buOrgCd}';
var cstTypCd = '${cstTypCd}';
var no = '${no}';
var mtgDesc = '${mtgDesc}';
var lnkCompNm = '${lnkCompNm}'; //挂靠公司名称
var s = '${mtg.pledgorNm}';
var checkDy = "${checkDy}";
var isFlow = "${isFlow}";
var prdGrid = null;
//var prjTypCd = "${prjTypCd}";//项目类型
var prdStsCd = "${prdStsCd}";//资产状态
var LSrecNo = "${LSrecNo}";//查询历史登记编号数据
var insCode = "${insCode}";//机构标识
var mtgInsJsonArray='${mtgInsJsonArray}';//抵押资方关系
$(function () {
if(detailFlag == "false" ){

	$("#YD").hide();
	$("#YD1").hide();
	$("#prj_prd_mtg_info_add_btn_id").show();

}
if(detailFlag == "true" && checkDy ==""){
	$("#YD").hide();
	$("#YD1").hide();
}
if(checkDy == "0"){
	$("#prj_prd_mtg_info_add_btn_id").hide();
} 
	 var ligerForm = liger.get("prj_prd_mtg_info_form");
		$("#prj_prd_mtg_info_form").ligerForm({
		    validate: true
		});
		setFormatDateValue();
		var pledgorNm = $("#pledgorNm").val();//债权人
		var pledgeeNm = $("#pledgeeNm").val();//抵押权人
		var mtgDeadline = $("#mtgDeadline").val(); //抵押期限
		//var mtgDeadline = '${mtg.mtgDeadline}'; //抵押期限
		var guarTypCd = $("#guarTypCd").val(); //抵押物种类
		var mtgPsnTypCd = $("#mtgPsnTypCd").val();//抵押人
		var sortNo = $("#sortNo").val();//抵押序号
		var guarDesc = $("#guarDesc").val();
		
		var outDay = '${mtg.isWithoutDay}';
		if(outDay&&outDay==1){
			liger.get('isWithoutDay').setValue(true);
		}else{
			liger.get('isWithoutDay').setValue(false);
		}
		if(!pledgorNm){
			$("#pledgorNm").val(cstNm);
		}
	//modify 项目资方，仅支持微众、三井 ,显示资方名称，其他显示狮桥
	var pledgeeAuthNm=$('#pledgeeAuthNm').val();
	var jsonobj = eval(mtgInsJsonArray)
	console.log("mmm"+mtgInsJsonArray);
	var isFlag=1;
	if(!pledgeeAuthNm){//抵押权人名称 姓名
		for(var i in jsonobj){
			var temp=jsonobj[i].code;
			if(insCode==temp){
				$('#pledgeeAuthNm').val(jsonobj[i].sortNo);
				isFlag=2;
			}
		}
		if(isFlag==1){
			$('#pledgeeAuthNm').val("1");
		}
	}
	var isFlag2=1;
	if(!pledgeeNm) {//抵押权人 签字
		for (var i in jsonobj) {
			var temp = jsonobj[i].code;
			if (insCode == temp) {
				$("#pledgeeNm").val(jsonobj[i].codeNm);
				isFlag2 = 2;
			}
		}
		if (isFlag2 == 1) {
			$("#pledgeeNm").val("狮桥融资租赁（中国）有限公司");
		}
	}
		if(!mtgDeadline){
			var id = '${mtg.id}';
			if(!id){
			$('[name="isWithoutDay"]').siblings('a').click();
			}else{
				var	isWithoutDay = $("#isWithoutDay").val();
				var flag = $('[name="isWithoutDay"]').prop('checked');
				if(!mtgDeadline&&flag==false){
					$('[name="isWithoutDay"]').siblings('a').click();
				}
			}
		}
		if(!lnkCompNm){
			liger.get("isLnkCompNm").setDisabled(true);
		}
		if(!guarTypCd){
			//根据事业部设置不同的默认值
			if(buOrgCd==ProjectConstant.CODE_BU_ORG_CD_CAR){
			//	$("#guarTypCd").val("4");
				
				liger.get("guarTypCd").setValue("4");
			}
			if(buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK){
				//$("#guarTypCd").val("5");
				liger.get("guarTypCd").setValue("5");
			}
		}
		
		if(!mtgPsnTypCd){
			if(buOrgCd==ProjectConstant.CODE_BU_ORG_CD_NJ){
				//$("#mtgPsnTypCd").val("3");
				
				liger.get("mtgPsnTypCd").setValue("3");
			}else{
				if(cstTypCd==CustomerConstant.CST_TYPE_NP_CD){
					//$("#mtgPsnTypCd").val("2");
					liger.get("mtgPsnTypCd").setValue("2");
				}
				if(cstTypCd==CustomerConstant.CST_TYPE_CORP_CD){
					//$("#mtgPsnTypCd").val("1");
					liger.get("mtgPsnTypCd").setValue("1");
				}
			}
		}
		if(!sortNo){
			$("#sortNo").val(no);
		}
		
		if(!guarDesc){
			$("#guarDesc").val(mtgDesc);
		}
		
	if(detailFlag =="true"){
		$("#prj_prd_mtg_info_add_btn_id").hide();
		//取消选择事件
		
		if(liger.get("licOrgNm")){
			liger.get("licOrgNm").setDisabled(true);
			}
		$("#licOrgNm").removeAttr('onfocus')
		// $("#licOrgNm").unbind("focus",selectLicOrg);
		  /*  $("#licOrgNm").focus(function(event) {
            event.preventDefault();
        });  */
		if($("#recNo")){
			$("#recNo").attr("readonly","readonly");
		}
		if($("#mtgDeadline")){
			$("#mtgDeadline").attr("readonly","readonly");
		}
		if($("#isWithoutDay")){
			$("#isWithoutDay").attr("readonly","readonly");
		}
		if(liger.get("mtgPsnTypCd")){
			liger.get("mtgPsnTypCd").setDisabled(true);
			}
		if($("#sortNo")){
			$("#sortNo").attr("readonly","readonly");
		}
		if(liger.get("guarTypCd")){
			liger.get("guarTypCd").setDisabled(true);
			}
		
		if($("#guarDesc")){
			$("#guarDesc").attr("readonly","readonly");
		}
		if($("#pledgorNm")){
			$("#pledgorNm").attr("readonly","readonly");
		}
		if($("#pledgorSignDt")){
			$("#pledgorSignDt").attr("readonly","readonly");
		}
		if($("#pledgeeNm")){
			$("#pledgeeNm").attr("readonly","readonly");
		}
		
		if($("#pledgeeSignDt")){
			$("#pledgeeSignDt").attr("readonly","readonly");
		}
		if($("#licOrgId")){
			$("#licOrgId").attr("readonly","readonly");
		}
		if($("#regAuthSignDt")){
			$("#regAuthSignDt").attr("readonly","readonly");
		}
		if(liger.get("mtgWayCd")){
			liger.get("mtgWayCd").setDisabled(true);
		}
	}
	
	//初始化列表
	var data = ${dtlData};
	initPrdGrid(data);
	setName();

});
//验证不通过
function NotYanZ(){
	var  DY = $("#YD1").attr("value");
		var guarTypCd = $("#guarTypCd").val()
		var mtgPsnTypCd = $("#mtgPsnTypCd").val()
		var pledgorNm ='${mtg.pledgorNm }';
		$.ajax({
			type: 'post',
			dataType:'json',
			data:{
				id:id,
				dtlId:id,
				DY:DY,
				pledgorNm:pledgorNm,
				pledgeeNm:'${mtg.pledgeeNm }',
				pledgorSignDt:'${mtg.pledgorSignDt}',
				pledgeeSignDt:'${mtg.pledgeeSignDt}',
				regAuthSignDt:'${mtg.regAuthSignDt}',
				licOrgId:'${mtg.licOrg.id }',
				recNo:'${mtg.recNo }',
				sortNo:'${mtg.sortNo }',
				guarTypCd:guarTypCd,
				mtgPsnTypCd:mtgPsnTypCd,
				mtgWayCd:'${mtg.mtgWayCd }'
			},
			url:'<%=path%>/project/prjprdmtg/add.do',
			success:function(msg){
				if(msg.success == 1){
					var callback=GET_W2Wcallback();
					if(callback) callback(false,'${mtg.mtgWayCd}');
					Remove_navTab(currentTabid);
				}
			}
		})
}
//验证通过
function YanZ() {
	//alert(1)
	 var  DY = $("#YD").attr("value");
		var guarTypCd = $("#guarTypCd").val()
		var mtgPsnTypCd = $("#mtgPsnTypCd").val()
		var pledgorNm ='${mtg.pledgorNm }';

		$.ajax({
			type: 'post',
			dataType:'json',
			data:{
				id:id,
				dtlId:id,
				DY:DY,
				pledgorNm:pledgorNm,
				pledgeeNm:'${mtg.pledgeeNm }',
				pledgorSignDt:'${mtg.pledgorSignDt}',
				pledgeeSignDt:'${mtg.pledgeeSignDt}',
				regAuthSignDt:'${mtg.regAuthSignDt}',
				licOrgId:'${mtg.licOrg.id }',
				recNo:'${mtg.recNo }',
				sortNo:'${mtg.sortNo }',
				guarTypCd:guarTypCd,
				mtgPsnTypCd:mtgPsnTypCd,
				mtgWayCd:'${mtg.mtgWayCd }'
			},
			url:'<%=path%>/project/prjprdmtg/add.do',
			success:function(msg){
				if(msg.success == 1){
					var callback=GET_W2Wcallback();
					if(callback) callback(true,'${mtg.mtgWayCd}');
					Remove_navTab(currentTabid);
				}
			}
		}) 
}
function passDy(_id,mtgWayCd){
	if(StringUtils.isNotEmpty(_id)){
		$.ajax({
    		type: 'post',
    		dataType:'json',
    		data:{id:_id,
    			  /*guarStsCd:ProjectConstant.CODE_GUAR_STS_MTG*/
				  mtgWayCd:mtgWayCd
    			},
    		url: '<%=path%>/capPay/flow/modifyDyStatus.do',
    		beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
    		success:function(msg){
    			 wait_dialog.close();
    			 if(msg.success == 1){
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
    				 if(isFlow==1){
    					console.log("执行Remove_navTab===抵押");
 		          	 	Remove_navTab();//关闭刷新前置tab页(YAOXIURONG-FLOW)
     				 }
  				   var TAB=top.mainApp.parentTab;
  			            var currentTabid=TAB.getSelectedTabItemID();
  			            var currFrameElement=top.$("#"+currentTabid).get(0);
  						 var callback=currFrameElement.W2W.callback;
			          	  		callback();
			          	 	 top.tab.removeTabItem(currentTabid); 
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
}

function setName(){
	$('[name="isLnkCompNm"]').siblings('a').click(function() { 
		var isLnkCompNm = $("#isLnkCompNm").val();
		if(isLnkCompNm=="true"){
			if(lnkCompNm){
			$("#pledgorNm").val('${lnkCompNm}');
			if($("#pledgorNm")){
				$("#pledgorNm").attr("readonly","readonly");
			}
			}
		}else{
			if($("#pledgorNm")){
				$("#pledgorNm").attr("readonly",false);
			}
			
		}
	});
}
function initPrdGrid(data){
	$("#prdGrid").ligerGrid({
		data:data,
        columns: [
            { display: '设备名称', name: 'prdNm', minWidth: 140, },
            { display: '设备型号', name: 'prdMdl', minWidth: 140, },
            { display: '数量', name: 'prdQty', minWidth: 80 ,enabledSort:true},
             { display: '资产状态', name: 'prdStsCd', 
            	render: function (rowdata, rowindex, value, column) { 
            		var h = '正常';
            		    
                        return h;
            		},	
            	minWidth: 140 , enabledSort:true}, 
        ],
        pageSize:100,
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        heightDiff:-2,
        checkbox:false,
        allowUnSelectRow: true,
        alternatingRow: false,
        rownumbers:false,
        usePagerOnLessPagesize: false,
    });
	prdGrid = liger.get("prdGrid");
	prdGrid.setHeight(100);
}
//设置日期值
function setFormatDateValue(){
	var pledgorSignDt ='${mtg.pledgorSignDt}';
	var pledgeeSignDt ='${mtg.pledgeeSignDt}';
	var regAuthSignDt ='${mtg.regAuthSignDt}';
	var mtgDeadline = '${mtg.mtgDeadline}';
	if(pledgorSignDt){
    	var pledgorSignDate = DateUtils.formatDate(new Date(pledgorSignDt),DateUtils.YYYY_MM_DD);
    	$("#pledgorSignDt").val(pledgorSignDate);//
    	$("#pledgorSignDtTxt").text(pledgorSignDate);
    	}
	
	if(pledgeeSignDt){
    	var pledgeeSignDate = DateUtils.formatDate(new Date(pledgeeSignDt),DateUtils.YYYY_MM_DD);
    	$("#pledgeeSignDt").val(pledgeeSignDate);//
    	$("#pledgeeSignDtTxt").text(pledgeeSignDate);
    	}
	
	if(regAuthSignDt){
    	var regAuthSignDate = DateUtils.formatDate(new Date(regAuthSignDt),DateUtils.YYYY_MM_DD);
    	$("#regAuthSignDt").val(regAuthSignDate);//
    	$("#regAuthSignDtTxt").text(regAuthSignDate);
    	}
	if(mtgDeadline){
    	var mtgDeadlineDate = DateUtils.formatDate(new Date(mtgDeadline),DateUtils.YYYY_MM_DD);
    	$("#mtgDeadline").val(mtgDeadlineDate);//
    	$("#mtgDeadlineTxt").text(mtgDeadlineDate);
    	}
	
}
function  selectLicOrg(){
    $.ligerDialog.open({title: '选择登记机关',height: 500,width: 850, url: '<%=path%>/project/prjprdlicorg/toListPage.do'});
}
	
	var isFlow = '${isFlow}';
	function savePrjPrdMtg(){
		  var ligerForm = liger.get("prj_prd_mtg_info_form");
		  //modify 当选择为无法抵押、上户自有公司时，保留抵押方式、登记证编号必填校验。其他必填证去掉
		  var mtgWayCd = $('#mtgWayCd').val();
		  if(mtgWayCd==''|| mtgWayCd.length==0 ||mtgWayCd==null){
			  top.$.ligerDialog.SQalert({content:"抵押方式不能为空！",SQ_type: "warning"});
			  return false;
		  }
		  var recNo=$('#recNo').val();//登记证编号
		  if(mtgWayCd=='2' || mtgWayCd=='3'){
			  if(recNo=="" || recNo.length==0 || recNo ==null){
				  top.$.ligerDialog.SQalert({content:"登记编号不能为空！",SQ_type: "warning"});
				  return false;
			  }
		  }else{
			  if (!ligerForm.valid()) {
				  top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				  return false; //验证不通过，不执行以下代码
			  }
		  }
		  console.log(mtgWayCd+"mtgWayCd");
		  var id = '${mtg.id}';
		  var no = '${mtg.recNo}';
			if(!id||(recNo&&recNo!=no)){
				var url = '<%=path%>/project/prjprdmtg/getPrjPrdMtgList.do';
					$.ajax({
				    		type: 'get',
				    		dataType:'json',
				    		data:{recNo:recNo,id:id},
				    		url: url,
				    		success:function(msg){
				    			 if(msg.success == 1){
				    		    		UIUtils.alertError(recNo+"，该登记编号已经存在！");
				    			 }
				    			 if(msg.success == 0){
				    					 save();
				    			 }
				    		}
				    	});
					  }else{
						  save();
					  }
	}
			
	function save(){
        var ligerForm = liger.get("prj_prd_mtg_info_form");
        /*if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }*/
        var data = ligerForm.getData();
        var url = '<%=path%>/project/prjprdmtg/add.do';
        var id = $("#mtgId").val();
        var data = ligerForm.getData();
        var mtgDeadline = $("#mtgDeadline").val();
        var fileParams = getUploadResultParams();//获取附件上传的信息
        data["id"]= id;
        data["dtlId"]= dtlId;
        data["licOrgId"]=$("#orgId").val();
        data["fileParams"] = JSON.stringify(fileParams);
        var wait_dialog;
        $.ajax({
    		type: 'post',
    		dataType:'json',
    		data:data,
    		url: url,
    		beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
    		success:function(msg){
    			 wait_dialog.close();
    			 if(msg.success == 1){
    				 $("#mtgId").val(msg.data);
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
    				 if(isFlow==1){
		          	 	Remove_navTab();//关闭刷新前置tab页(YAOXIURONG-FLOW)
    				 }
  				   	 var TAB=top.mainApp.parentTab;
  			            var currentTabid=TAB.getSelectedTabItemID();
  			            var currFrameElement=top.$("#"+currentTabid).get(0);
  						 var callback=currFrameElement.W2W.callback;
			          	  		callback();
			          	 	 top.tab.removeTabItem(currentTabid); 
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
	function setMtgDate(){
		//设置抵押时间
		var pledgorSignDt = $("#pledgorSignDt").val();
		if(pledgorSignDt){
			//设置其他的日期
			$("#pledgeeSignDt").val(pledgorSignDt);
			$("#regAuthSignDt").val(pledgorSignDt);
			  //liger.get("pledgeeSignDt").setDisabled();
			 // liger.get("regAuthSignDt").setDisabled();
		}
	}
	//设置债权人名称为挂靠公司名称
	function setPledgorNm(){
		var isLnkCompNm = $("#isLnkCompNm")[0].value;
		var flag = $('[name="isLnkCompNm"]').prop('checked');
		if(flag){
			if(lnkCompNm){
			$("#pledgorNm").val('${lnkCompNm}');
			if($("#pledgorNm")){
				  liger.get("pledgorNm").setDisabled();
			}
			}
		}else{
			if($("#pledgorNm")){
				 liger.get("pledgorNm").setEnabled();
			}
			
		}
	}
	
	function setIsWithoutDayValue(){
		var mtgDeadline = $("#mtgDeadline").val();
		if(mtgDeadline){
			//
			liger.get('isWithoutDay').setValue(false);
		}
	}
	
	function setMtgDeadlineValue(){
		var isWithoutDay = $("#isWithoutDay").val();
		if(isWithoutDay=="on"){
			$("#mtgDeadline").val("");
		}
	}

//add 抵押权人名称（姓名） 抵押方式为无法抵押、上户自有公司：为空
var aFlag=1;
function changePledgeeAuthNm(obj){
	var value=$(obj).val();
	if(aFlag==1){
		aFlag=2;
		return ;
	}
	if(value!=null && value!='' &&(value=='2' || value=='3')){
		$('#pledgeeAuthNmDiv').html("");
		$('#pledgeeAuthNmDiv1').html("");
		$('#pledgeeAuthNmDiv2').html("");
		$('#pledgeeAuthNm').val("");
	}else{
		if(value=='4'){
		}else{
			$('#pledgeeAuthNm').val("1");
			$('#pledgeeAuthNmDiv1').html("狮桥融资租赁中国有限公司");
			$('#pledgeeAuthNmDiv2').html("狮桥融资租赁中国有限公司");
		}

	}
}

    </script>
</body>
</html>